package client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

import common.PrintSupp;


public class Client {

	Socket socket;
	BufferedReader in;
	PrintWriter out;

	public Client() {
		try {
			while(true){
				socket = new Socket("127.0.0.1", 10000);
				in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
				out = new PrintWriter(socket.getOutputStream(), true);
				BufferedReader line = new BufferedReader(new InputStreamReader(System.in));
				String info = line.readLine();
				if(isHelper(info)){
					commonHelper();
				}
				out.println(info);
				System.out.println(in.readLine());
			}
		} catch (IOException e) {
		}
	}

	static private boolean isHelper(String line){
		line = line.trim();
		if(line.equals("?")||line.equals("help")){
			return true;
		}else{
			return false;
		}
	}
	
	static private void commonHelper(){
		PrintSupp.printCommonCMD();
		PrintSupp.printCommonTyps();
	}
	
	public static void main(String[] args) {
		new Client();
	}

}
